#include "STTabTest.h"
#include "Blueprint/UserWidget.h"
#include "Slate.h"
#include "Blueprint/UserWidget.h"
#include "Widgets/Layout/SScaleBox.h"
#include "Framework/Docking/TabManager.h"

#include "Framework/Application/SWindowTitleBar.h"
#include "Widgets/Notifications/SNotificationList.h"
#include "Widgets/SCompoundWidget.h"


#include "Framework/Application/SlateApplication.h"

#define LOCTEXT_NAMESPACE "STTabTest"

TSharedRef<SDockTab> FSTTabTestToolkit::OnSpawnTab_Test(const FSpawnTabArgs& Args) 
{
	TSharedPtr<SDockTab> DetailsTab = SNew(SDockTab)
		//.Icon(FDisplayClusterConfiguratorStyle::GetBrush("DisplayClusterConfigurator.Tabs.General"))
		.Label(LOCTEXT("StoneTab", "StoneTab"));

	return DetailsTab.ToSharedRef();
}

TSharedRef<SDockTab> FSTTabTestToolkit::OnSpawnTab_Viewport(const FSpawnTabArgs& Args)
{
	verticalBox = SNew(SVerticalBox);


	TSharedPtr<SDockTab> ViewportTab = SNew(SDockTab)
		.Label(LOCTEXT("ViewportTab_Title", "Viewport"))
		[
			verticalBox.ToSharedRef()
		];


		return ViewportTab.ToSharedRef();

}




void FSTTabTestToolkit::CreateEditorLayout(TWeakPtr<SWindow> window, FVector2D windowSize, FVector2D windowPos)
{


	TSharedRef<FGlobalTabmanager> globalTabmanager = FGlobalTabmanager::Get();
	

	globalTabmanager->RegisterTabSpawner("TestSuite1", FOnSpawnTab::CreateRaw(this, &FSTTabTestToolkit::OnSpawnTab_Test));
	//globalTabmanager->RegisterTabSpawner("stoneViewPoint", FOnSpawnTab::CreateRaw(this, &FSTTabTestToolkit::OnSpawnTab_Viewport));



	TSharedRef<FTabManager::FLayout> Layout = FTabManager::NewLayout("SlateTestSuite_Layout")
		->AddArea
		(
			FTabManager::NewArea(windowSize.X, windowSize.Y)
			->SetWindow(FVector2D(windowPos.X, windowPos.Y), false)
			->Split
			(
				FTabManager::NewStack()
				
				->AddTab("TestSuite1", ETabState::OpenedTab)
				//->AddTab("stoneViewPoint", ETabState::OpenedTab)
				//->AddTab("RenderTransformManipulator", ETabState::OpenedTab)
				//->AddTab("WidgetGalleryTab", ETabState::OpenedTab)
				//->SetForegroundTab(FName("TestSuite1"))
			)
		);


	//rootWindow = GEngine->GameViewport->GetWindow();

	FGlobalTabmanager::Get()->RestoreFrom(Layout,nullptr);

	window.Pin()->HideWindow();
	//window.Pin()->RequestDestroyWindow();
}


#undef LOCTEXT_NAMESPACE
